]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/scrollview: Add ::content-padding property to StScrollView
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 19 Feb 2021 15:42:34 +0000 (16:42 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Mar 2021 22:02:56 +0000 (22:02 +0000)
This will be needed for fine tuning of the visible area for appGrid
navigation purposes. We most nominally can let it happen via CSS as
the size calculations happen on size allocate, so we want to avoid
triggering relayouts while adapting to the given size.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1630>

src/st/st-scroll-view-fade.c
src/st/st-scroll-view.c

index 38d40ed651ec23b9b7d0d34e79c5616ebc7f2219..3ca73133729b7069c6b0d22f8e83fdd404ec8a1c 100644 (file)
@@ -97,6 +97,7 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
   gboolean h_scroll_visible, v_scroll_visible;
 
   ClutterActorBox allocation, content_box, paint_box;
+  ClutterMargin *content_padding;
 
   float fade_area_topleft[2];
   float fade_area_bottomright[2];
@@ -108,6 +109,13 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
   clutter_actor_get_allocation_box (self->actor, &allocation);
   st_theme_node_get_content_box (st_widget_get_theme_node (ST_WIDGET (self->actor)),
                                 (const ClutterActorBox *)&allocation, &content_box);
+  g_object_get (self->actor, "content-padding", &content_padding, NULL);
+
+  content_box.x1 += content_padding->left;
+  content_box.x2 -= content_padding->right;
+  content_box.y1 += content_padding->top;
+  content_box.y2 -= content_padding->bottom;
+  clutter_margin_free (content_padding);
 
   /*
    * The FBO is based on the paint_volume's size which can be larger then the actual
index 3b9711ea216f3b5539e9751aacced22e9ea51fd9..606701565d12b327cb099bb9a55b2f1e5032060b 100644 (file)
@@ -84,6 +84,8 @@ struct _StScrollViewPrivate
   StAdjustment *vadjustment;
   ClutterActor *vscroll;
 
+  ClutterMargin content_padding;
+
   StPolicyType hscrollbar_policy;
   StPolicyType vscrollbar_policy;
 
@@ -116,6 +118,7 @@ enum {
   PROP_VSCROLLBAR_VISIBLE,
   PROP_MOUSE_SCROLL,
   PROP_OVERLAY_SCROLLBARS,
+  PROP_CONTENT_PADDING,
 
   N_PROPS
 };
@@ -156,6 +159,9 @@ st_scroll_view_get_property (GObject    *object,
     case PROP_OVERLAY_SCROLLBARS:
       g_value_set_boolean (value, priv->overlay_scrollbars);
       break;
+    case PROP_CONTENT_PADDING:
+      g_value_set_boxed (value, &priv->content_padding);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -233,6 +239,9 @@ st_scroll_view_set_property (GObject      *object,
                                  priv->hscrollbar_policy,
                                  g_value_get_enum (value));
       break;
+    case PROP_CONTENT_PADDING:
+      priv->content_padding = * (ClutterMargin *) g_value_get_boxed (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -545,6 +554,11 @@ st_scroll_view_allocate (ClutterActor          *actor,
 
   st_theme_node_get_content_box (theme_node, box, &content_box);
 
+  content_box.x1 += priv->content_padding.left;
+  content_box.x2 -= priv->content_padding.right;
+  content_box.y1 += priv->content_padding.top;
+  content_box.y2 += priv->content_padding.bottom;
+
   avail_width = content_box.x2 - content_box.x1;
   avail_height = content_box.y2 - content_box.y1;
 
@@ -933,6 +947,13 @@ st_scroll_view_class_init (StScrollViewClass *klass)
                           FALSE,
                           ST_PARAM_READWRITE);
 
+  props[PROP_CONTENT_PADDING] =
+    g_param_spec_boxed ("content-padding",
+                        "Content padding",
+                        "Content padding",
+                        CLUTTER_TYPE_MARGIN,
+                        ST_PARAM_READWRITE);
+
   g_object_class_install_properties (object_class, N_PROPS, props);
 }